/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { numDefine512 } from './DevNumber';
class CommonVariable {
  rg0: number = 0;
  fg0: number = 0.0;
  rg1: number = 0;
  heapNewPos: number = numDefine512;
  abort: boolean = false;
  mandreelDisableSpaceKey: boolean = true;
  mandreelFatData: string = '';
  gMandreelWorkingFolder: string = 'DataPC/';
  mandreelCurrentTime: number = 0;
  mandreelPauseTimes: Array<number> = new Array();
  mandreelSampleTimeStart: number = 0.0;
  mandreelAudioDriver: string = 'null';
  mandreelAppPlatform: string = 'webgl';
  gAddrEmit: number = 0;
}

class HeapClass {
  heap: ArrayBuffer = new ArrayBuffer(0);
  heap8: Int8Array = new Int8Array();
  heapU8: Uint8Array = new Uint8Array();
  heap16: Int16Array = new Int16Array();
  heapU16: Uint16Array = new Uint16Array();
  heap32: Int32Array = new Int32Array();
  heapU32: Uint32Array = new Uint32Array();
  heapFloat: Float32Array = new Float32Array();
  heapDouble: Float64Array = new Float64Array();
  myHeap: ArrayBuffer = new ArrayBuffer(0);
  myHeap8: Int8Array = new Int8Array();
  myHeap32: Int32Array = new Int32Array();
}

let heapClassInst = new HeapClass();

let commonVariable = new CommonVariable();

function nullMandreelAudio(sp: number): void {
  commonVariable.rg0 = 0;
}

function mandreelAudioUseMusicFunctions(sp: number): void {
  commonVariable.rg0 = 0;
}

export { commonVariable, heapClassInst, nullMandreelAudio, mandreelAudioUseMusicFunctions };
